package com.itheima.appserver.controller;

import com.itheima.appserver.service.PeachblossomService;
import com.itheima.commons.model.vo.PeachVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


@RequestMapping("peachblossom")
@RestController
public class PeachblossomController {

    @Autowired
    private PeachblossomService peachblossomService;

    /**
     * 接受语音
     *
     * @return
     */
    @GetMapping()
    public ResponseEntity getPeachblossom() {
        PeachVo peachVo = peachblossomService.getPeachblossom();
        return ResponseEntity.ok(peachVo);
    }

    /**
     * 发送语音
     * @param soundFile
     * @return
     */
    @PostMapping()
    public ResponseEntity sendPeachblossom(@RequestParam("soundFile") MultipartFile soundFile) {
        peachblossomService.sendPeachblossom(soundFile);
        return ResponseEntity.ok(null);
    }
}
